package com.knoya.chejian.pda.myadapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.knoya.chejian.pda.R
import com.knoya.chejian.pda.module.zupan.ZupanBean
import com.knoya.chejian.pda.util.Myutil
import kotlinx.android.synthetic.main.item_zupan_package.view.*

class ZupanAdapter(private var mlist: List<ZupanBean>, private val mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v : View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.item_zupan_package,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        var bean = mlist[position]
        Myutil.settv(bean.pallet_num,h.TV_num)
        Myutil.settv(bean.pcode,h.Tv_Pcode)
        Myutil.settv(bean.status_name,h.Tv_Zhuangtai)
        if(bean.pallet_num == ""){
            Myutil.settv(bean.wp_warehouse,h.TV_num)
        }
        return v
    }

    override fun getItem(position: Int): Any {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return mlist.size
    }

    class Header(var v : View){
        val Tv_Zhuangtai=v.Tv_Zhuangtai
        val Tv_Pcode=v.Tv_Pcode
        val TV_num=v.TV_num

    }
}